package com.neuedu.nevserver.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.neuedu.nevserver.pojo.SlauBatch;
import com.neuedu.nevserver.mapper.SlauBatchMapper;
import com.neuedu.nevserver.service.SlauBatchService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.neuedu.nevserver.vo.NodeSlauBatchProdcutTypeVO;
import com.neuedu.nevserver.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author sjy
 * @since 2025-03-18
 */
@Service
public class SlauBatchServiceImpl extends ServiceImpl<SlauBatchMapper, SlauBatch> implements SlauBatchService {

    @Autowired
    private SlauBatchMapper slauBatchMapper;

    @Override
    public ResultVO<List<SlauBatch>> listSlauBatch(SlauBatch slauBatch) throws Exception{
        QueryWrapper qw = new QueryWrapper();
        if(slauBatch.getSbId()!=null){
            qw.eq("sb_id", slauBatch.getSbId());
        }
        if(slauBatch.getBatchId()!=null && !slauBatch.getBatchId().equals("")){
            qw.eq("batch_id", slauBatch.getBatchId());
        }
        if(slauBatch.getNodeId()!=null){
            qw.eq("node_id", slauBatch.getNodeId());
        }
        if(slauBatch.getType()!=null && !slauBatch.getType().equals("")){
            qw.eq("type", slauBatch.getType());
        }
        if(slauBatch.getState()!=null) {
            qw.eq("state", slauBatch.getState());
        }
        return ResultVO.success(null, slauBatchMapper.selectList(qw));
    }

    @Override
    public ResultVO<List<NodeSlauBatchProdcutTypeVO>> selectNodeSlauBatchProdcutTypeVO(Integer fbId) throws Exception {
        return ResultVO.success(null,slauBatchMapper.selectNodeSlauBatchProdcutTypeVO(fbId));
    }
}
